// number.js

var inType = "";//code,number
function DoInit(iType)
{
    var sTag = tagName.toLowerCase();
    inType = iType;

	if (sTag == "input" || sTag == "textarea" ) 
    {
		attachEvent("onkeypress",doKeyPress);
		
		this.value=this.value.replace(/(^\s*)|(\s*$)/g, "");
    }
}

function doKeyPress() {
	formatNumber(this);
}

function formatNumber(field)  {
	if (event.keyCode == 8 ) {
      event.keyCode == 8;
	  event.returnValue = true;
	  return;
    }
    else if (event.keyCode==9){
    	event.returnValue = true;
    	return;
    }
	else if (event.srcElement.tagName != "TEXTAREA" && event.keyCode == 13) {
	  event.keyCode = 9;
      event.returnValue = true;
	  return;
    }
	else if (event.keyCode >= 48 && event.keyCode <= 57 ) {
		  event.returnValue = true;
		  return;
    }
	else if (inType=="code" &&
				( (event.keyCode >= 65 && event.keyCode <= 90)
					|| (event.keyCode >= 97 && event.keyCode <= 122) )
					 ) {
		  event.returnValue = true;
		  return;
    }
	else {
      event.returnValue = false;
    }

}

